<template>
  <view>
    <view class="stauts" :style="{height:getStatusBarHeight + 'px'}"></view>
    <view class="indexTitle" :style="{height: getTitleBarHeight + 'px'}">
      <view class="fl" :style="{height:getTitleBarHeight + 'px'}">
        <text>郑州</text>
        <img src="../../static/img/icon01.png" alt="">
      </view>
      <view class="center">首页</view>
    </view>
    <view class="search">
      <input type="text" placeholder="请输入关键词搜索需要的服务">
      <img src="../../static/img/icon02.png" alt="">
      <view class="btn">搜索</view>
    </view>
    <view class="main">
      <view class="banner">
        <swiper class="swiper"
          circular
          :indicator-pos="'bottom'"
          :indicator-color="'rgba(255,255,255,0.5)'"
          :indicator-active-color="'#fff'"
          :indicator-dots="true"
          :autoplay="true"
          :interval="2000"
          :duration="500">
          <swiper-item>
            <view class="swiper-item uni-bg-red">
              <img src="../../static/img/icon01.png" alt="">
            </view>
          </swiper-item>
          <swiper-item>
            <view class="swiper-item uni-bg-red">
              <img src="../../static/img/icon01.png" alt="">
            </view>
          </swiper-item>
          <swiper-item>
            <view class="swiper-item uni-bg-red">
              <img src="../../static/img/icon01.png" alt="">
            </view>
          </swiper-item>
          <swiper-item>
            <view class="swiper-item uni-bg-red">
              <img src="../../static/img/icon01.png" alt="">
            </view>
          </swiper-item>
        </swiper>
      </view>
      <view class="navOne">
        <view class="li active">
          <img src="../../static/img/png01.png" alt="">
          <view class="h1">体育运动</view>
        </view>
        <view class="li">
          <img src="../../static/img/png02.png" alt="">
          <view class="h1">医院陪诊</view>
        </view>
        <view class="li">
          <img src="../../static/img/png03.png" alt="">
          <view class="h1">旅游规划</view>
        </view>
      </view>
      <view class="navTwo">
        <scroll-view class="scrollView"
                     scroll-x="true"
                     show-scrollbar="false"
                     :scroll-with-animation="true"
        >
          <view class="li">
            <text>羽毛球</text>
            <img class="xian" src="../../static/img/icon04.png" alt="">
            <img class="yuan" src="../../static/img/icon03.png" alt="">
          </view>
          <view class="li active">
            <text>网球</text>
            <img class="xian" src="../../static/img/icon04.png" alt="">
            <img class="yuan" src="../../static/img/icon03.png" alt="">
          </view>
          <view class="li">
            <text>台球</text>
            <img class="xian" src="../../static/img/icon04.png" alt="">
            <img class="yuan" src="../../static/img/icon03.png" alt="">
          </view>
          <view class="li">
            <text>羽毛球</text>
          </view>
          <view class="li">
            <text>网球</text>
          </view>
          <view class="li">
            <text>台球</text>
          </view>
          <view class="li">
            <text>羽毛球</text>
          </view>
          <view class="li">
            <text>网球</text>
          </view>
          <view class="li">
            <text>台球</text>
          </view>
          <view class="li">
            <text>羽毛球</text>
          </view>
          <view class="li">
            <text>网球</text>
          </view>
          <view class="li">
            <text>台球</text>
          </view>
          <view class="li">
            <text>羽毛球</text>
          </view>
          <view class="li">
            <text>网球</text>
          </view>
          <view class="li">
            <text>台球</text>
          </view>
        </scroll-view>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    components: {

    },
    data () {
      return {
        getStatusBarHeight:0,
        getTitleBarHeight:0,
      }
    },
    onLoad() {
      this.getStatusBarHeight = uni.getSystemInfoSync().statusBarHeight || 15;
      this.getTitleBarHeight = this.getTitleBarHeightFun();
      console.log(this.getStatusBarHeight)
      console.log(this.getTitleBarHeight)
    },
    onShow(){

    },
    methods: {
      getTitleBarHeightFun(){
        if (uni.getMenuButtonBoundingClientRect) {
          let {
            top,
            height
          } = uni.getMenuButtonBoundingClientRect();
          return height + (top - this.getStatusBarHeight) * 2;
        } else {
          return 40;
        }
      },
    }
  }
</script>
<style>
  page{
    background: #f5f5f5;
  }
</style>
<style lang="less" scoped>
  .stauts{
    background: #fff;
  }
  .indexTitle{
    position: relative;
    background: #fff;
    .fl{
      position: absolute;
      top:0;
      left: 25rpx;
      display: flex;
      align-items: center;
      width: 115rpx;
      text-align: center;
      text{
        font-size: 30rpx;
      }
      img{
        width: 22rpx;
        height: 11rpx;
      }
    }
    .center{
      position: absolute;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      text-align: center;
      font-size: 33rpx;
      color: #222;
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }
  .search{
    height: 89rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 25rpx;
    background: #fff;
    position: relative;
    input{
      width: 100%;
      height: 70rpx;
      border-radius: 70rpx;
      background: #f5f5f5;
      border: none;
      padding-left: 80rpx;
      font-size: 26rpx;
    }
    img{
      width: 28rpx;
      height: 28rpx;
      position: absolute;
      left: 59rpx;
      top: 50%;
      transform: translateY(-50%);
      z-index: 2;
    }
    .btn{
      width: 100rpx;
      height: 60rpx;
      border-radius: 60rpx;
      line-height: 60rpx;
      text-align: center;
      font-size: 26rpx;
      background: #3476ff;
      color: #fff;
      position: absolute;
      right: 30rpx;
      top: 50%;
      transform: translateY(-50%);
      z-index: 2;
    }
  }
  .main{
    padding: 0 25rpx;
    .banner{
      margin-top: 20rpx;
      .swiper{
        height: 300rpx;
        border-radius: 10rpx;
        overflow: hidden;
        .swiper-item{
          img{
            width: 100%;
            height: 300rpx;
          }
        }
      }
    }
    .navOne{
      display: flex;
      justify-content: space-between;
      margin-top: 40rpx;
      .li{
        width: 210rpx;
        border-radius: 10rpx;
        background: #fff;
        padding: 20rpx 0 35rpx 0;
        text-align: center;
        box-shadow: 0 0 5rpx rgba(0,0,0,0.15);
        img{
          width: 140rpx;
          height: 140rpx;
          display: inline-block;
        }
        .h1{
          font-size: 30rpx;
          margin-top: 20rpx;
        }
        &.active{
          background: #dfe9ff;
        }
      }
    }
    .navTwo{
      margin-top: 28rpx;
      .scrollView{
        white-space: nowrap;
        height: 85rpx;
        line-height: 85rpx;
        width: 100%;
        .li{
          display: inline-block;
          font-size: 30rpx;
          position: relative;
          padding: 0 20rpx;
          img{
            display: none;
            &.xian{
              width: 5rpx;
              height: 30rpx;
              position: absolute;
              left: 0;
              top: 50%;
              transform: translateY(-50%);
            }
            &.yuan{
              width: 75rpx;
              height: 75rpx;
              position: absolute;
              left: 50%;
              top: 50%;
              transform: translate(-50%,-50%);
            }
          }
          text{
            position: relative;
            z-index: 2;
          }
          &:last-child{
            margin-right: 20rpx;
          }
          &.active{
            img{
              display: block;
            }
          }
        }
      }
    }
  }
</style>